package itdfq.dfq.Structural_Patterns.xiangyuan;

import java.util.ArrayList;

/**
 * @Author GocChin
 * @Date 2021/4/20 10:45
 * @Blog: itdfq.com
 * @QQ: 909256107
 */
public class Factory {
    private ArrayList cards = new ArrayList();

    private int totalTerminal = 0;
    public Factory(){

        Demo1 demo1 = new Demo1("第一桌");
        cards.add(demo1);
        Demo2 demo2 = new Demo2("第二桌");
        cards.add(demo2);
    }
    public Puke getPuke(String name){
        if (name.equals("one")){
            totalTerminal++;
            return (Puke) cards.get(0);
        }else if(name.equals("two")){
            totalTerminal++;
            return (Puke) cards.get(1);
        }else {
            return null;
        }
    }

    public int getTotalTerminal() {
        return totalTerminal;
    }

    public int getTptalCards() {
        return cards.size();
    }
}
